/**
 * 学习目标：ref
 */
import React from 'react';
import ReactDOM from 'react-dom';

class App extends React.Component {
  // 创建ref对象
  ipt = React.createRef();
  render() {
    return (
      <div>
        {/* 绑定在dom或者组件身上 */}
        <input type="text" ref={this.ipt} />
        <button onClick={this.handel}>点击</button>
      </div>
    );
  }
  handel = () => {
    console.log('this.ipt  ----->  ', this.ipt);
    this.ipt.current.focus();
    const res = this.ipt.current.value;
    console.log('res  ----->  ', res);
  };
}

ReactDOM.render(<App></App>, document.getElementById('root'));
